const newlist = document.querySelector('#news-list')
const renderlist = async () => {
  const { data: res } = await axios({
    url: 'http://ajax-api.itheima.net/api/news',
    method: 'GET',
  })
  console.log(res)
  newlist.innerHTML = res
    .map(({ data: item }) => {
      console.log(item)
      return ` <div class="news-item">
<img
class="thumb"
src="${item.img}"
alt=""
/>
<div class="right-box">
<!-- 新闻标题 -->
<h1 class="title">${item.source}</h1>
<div class="footer">
<div>
  <!-- 新闻来源 -->
  <span>${item.title} </span>&nbsp;&nbsp;
  <!-- 发布日期 -->
  <span>${item.time} </span>
</div>
<!-- 评论数量 -->
<span>评论数: ${item.cmtcount} </span>
</div>
</div>
</div>`
    })
    .join('')
}
renderlist()
